<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Contact List</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            padding-top: 20px;
        }
        h1 {
            color: #007bff;
        }
        table {
            margin: 0 auto;
            border-collapse: collapse;
            width: 80%;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        th, td {
            padding: 12px 15px;
            text-align: center;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        form {
            margin-top: 20px;
        }
        input[type="submit"] {
            background-color: #007bff;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        a {
            text-decoration: none;
            color: #007bff;
            padding: 6px 12px;
            border: 1px solid #007bff;
            border-radius: 4px;
        }
        a:hover {
            background-color: #007bff;
            color: white;
        }
    </style>
</head>
<body>
<h1>Contact List</h1>
<table>
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>地址</th>
        <th>电话</th>
    </tr>

    <c:forEach var="contact" items="${contacts}">
        <tr>
            <td>${contact.id}</td>
            <td>${contact.name}</td>
            <td>${contact.address}</td>
            <td>${contact.phone}</td>
            <td>
                <form action="deleteContact" method="post">
                    <input type="hidden" name="contactId" value="${contact.id}">
                    <input type="submit" value="Delete">
                </form>
            </td>
            <td>
                <a href="/updateContact.jsp?contactId=${contact.id}">Edit</a>
            </td>
        </tr>
    </c:forEach>
</table>
<form action="addContact.jsp">
    <input type="submit" value="Add Contact">
</form>
</body>
</html>
